package org.example.view;

import javax.swing.*;
import java.awt.*;

public class DemoG extends JFrame {
    private JLabel l1, l2;

    public DemoG() throws HeadlessException {
        // 标题 一般书写在第一行
        setTitle("我的第一个界面");

        l1 = new JLabel("我是文本内容");
        Icon icon = new ImageIcon("/Users/dailyblue/workspace/java/IdeaProjects/jiazhong-shangluo-keshe-2025/images/img.png");
        l2 = new JLabel(icon);
        add(l1, BorderLayout.NORTH);
        add(l2);
        // 设置尺寸和位置
        int x = 500;
        int y = 400;
        int width = 960;
        int height = 1280;
        setBounds(x, y, width, height);
        // 设置窗体剧中显示
        setLocationRelativeTo(null);
        // 设置点击关闭时释放内存
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        // 配置显示
        setVisible(true);
    }

    public static void main(String[] args) {
        new DemoG();
    }
}
